package com.sntk.organauthomanager.application.mapper;

import com.sntk.organauthomanager.application.dto.UserRoleDTO;
import com.sntk.organauthomanager.infrastructure.db.entity.UserRoleEntity;
import org.springframework.stereotype.Component;

@Component
public class UserRoleMapper {

    public UserRoleDTO transformToDTO(UserRoleEntity userRoleEntity){

        return new UserRoleDTO(userRoleEntity.getId(),
                userRoleEntity.getUname(),
                userRoleEntity.getInstitutionNumber(),
                userRoleEntity.getRoleCode(),userRoleEntity.getCreateTime(),
                userRoleEntity.getCreator());
    }

    public UserRoleEntity transformToEntity(UserRoleDTO userRoleDTO){
        UserRoleEntity userRoleEntity = new UserRoleEntity();
        userRoleEntity.setCreator(userRoleDTO.getCreator())
        .setCreateTime(userRoleDTO.getCreateTime())
        .setInstitutionNumber(userRoleDTO.getInstitutionNumber())
        .setRoleCode(userRoleDTO.getRoleCode())
        .setUname(userRoleDTO.getUname())
        .setId(userRoleDTO.getId())
        ;

        return userRoleEntity;
    }

}
